<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta
			name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"
		/>
		<meta name="format-detection" content="telephone=yes" />
		<meta name="format-detection" content="email=no" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Cache-Control" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<title></title>
		<!-- 引入 vant UI 组件库样式文件 -->
		<link rel="stylesheet" href="../common/css/vant-index.css" />
		<link rel="stylesheet" href="../common/css/common.css" />
		<link rel="stylesheet" href="css/doctor.css" />
		<!-- <style type="text/css">
			.van-card{
				background:#ffffff;
				border-bottom: 1px solid rgba(187, 187, 187, 0.3);
				margin: 0 0.2rem;
				padding-left: 0;
				padding-right: 0;
			}
			.van-card:last-of-type{
				border-bottom: none;
			}
			.van-card__thumb{
				width: 60px;
				height: 60px;
				border-radius: 8px;
				overflow: hidden;
				margin-right:0.3rem
			}
			.van-card__content{
				min-height: 0;
			}
			.van-card__title{
				font-size: 16px;
				line-height: 30px;
				font-weight: normal;
			}
		</style>
	 -->
	</head>

	<body>
		<div id='app' v-cloak>
			<div class="id_container">
				<div class="mm_top">
					<div class="doctor_left_title" style="margin-top: 0;">
						<span class="doctor_left_title_border" v-if='!from'></span>
						<span class="doctor_left_title_border" v-else style='background-color: #01CD9C;'></span>
						<span class="doctor_left_title_name">{{sub_title}}</span>
					</div>
					<div class="mm_addmin" v-if='!from'>
						<img src="img/manage/add-o.png" @click="addMember"/>
						<img src="img/manage/minus-o.png" @click="showBadge"/>
					</div>
				</div>

				<div class="doctor_box mm_list" v-if="nothing==1">
					<ul>
						<li v-for="item in doctorTeam">
							<div class="mm_t">
								<div class="mm_t_left" @click="linkToDoctor(item.dataId)">
									<div class="mm_t_left_avater">
										<img v-if="item.doctorAvatar" :src="item.doctorAvatar"/>
										<img v-else src="img/logo.png"/>
									</div>
									<div class="badge" v-if="showbadge" @click.stop="deleteMember(item.dataId)">
										<p class="">—</p>
									</div>
									<div class="mm_t_left_info">
										<p class="mm_t_left_info_name">{{item.doctorName}}</p>
										<p class="mm_t_left_info_level">{{item.doctorTypeName}}</p>
									</div>
								</div>
								<div class="mm_t_left_right" @click="call(item.doctorMobile)">
									<img src="img/icon_phone.png"/>
								</div>
							</div>
						</li>
					</ul>

				</div>
				<van-empty v-if="nothing==2"
							  class="custom-image"
							  image="img/blank_pic.png"
							  description="暂无成员，请组建自己的团队"
							/>
			</div>
			<link-index v-if='!from'></link-index>
		</div>
	</body>
	<!-- 引入 rem -->
	<script src="../common/js/rem.js"></script>
	<!-- 上线环境用 -->
	<script src="../common/js/vue.global.prod.js"></script>
	<!-- 引入 UI 组件库 -->
	<script src="../common/js/vant.min.js"></script>
	<!-- axios 接口调用 -->
	<script src="../common/js/axios.min.js"></script>
	<script src="../base.js"></script>
	<script src="../common/js/url.min.js"></script>
	
	<script type="module">
		import {
			getAction,
			postAction,
			spliceUrl,
		} from "../common/js/api/vue3-axios-utils.js";

		import { linkIndex } from "../common/js/template/linkIndex.js"

		const PatientData = {
			data() {
				return {
					url: {
						getTeam:'/201/03/2010301',
						deleteMember:'/201/03/2010303'
					},
					doctorId:'',
					detail:{},
					doctorTeam:[],
					showbadge:false,
					nothing:1,
					user:'doctor'
				};
			},
			created() {
				this.doctorId = url('?id')
				if(url('?from')){
					this.from = url('?from')
					if(url('?from')=='weapp'){
						this.sub_title = '医师团队'
						document.title = '医师团队'
						this.user = 'patient'
					}else{
						this.sub_title = '我的团队'
						document.title = '成员管理'
					}
					
				}else{
					this.sub_title = '我的团队'
					document.title = '成员管理'
				}
				this.init()
			},
			methods: {
				async init () {
	                await this.handleGetTeam();
	           },
				handleGetTeam(){
					getAction(spliceUrl(this.url.getTeam),{doctorId:this.doctorId,user:this.user}).then((res) => {
						res = res.data
						console.log('handleGetTeam',res)
						if(res.success){
							this.doctorTeam = []
							if(res.result.teamDoctors.length!=0){
								this.nothing = 1
								this.doctorTeam = res.result.teamDoctors
								this.doctorTeamId = res.result.teamId
							}else{
								this.nothing = 2
							}

						}
					})
				},
				handleDeleteMember(did){
					postAction(spliceUrl(this.url.deleteMember),{doctorId:did,teamId:this.doctorTeamId}).then((res) => {
						res = res.data
						console.log('handleDeleteMember',res)
						if(res.success){
							this.handleGetTeam()
							this.showbadge = false
						}
					})
				},
				call(id){
					console.log('call')
					window.location.href = 'tel://' + id
				},
				linkToDoctor(id){
					if(this.from){
						window.location.href = 'doctorInfo.html?id='+id+'&from='+this.from
					}else{
						window.location.href = 'doctorInfo.html?id='+id
					}
				},
				showBadge(){
					this.showbadge = true
				},
				addMember(){
					window.location.href = 'qrcode.html?tab=1&id='+this.doctorId
				},
				deleteMember(id){
					this.$dialog.confirm({
				    		message:'是否确定将该成员移除'
				   	}).then(()=>{
				    		this.handleDeleteMember(id)
				   	}).catch(() => {
					    this.showbadge = false
					});
				}
			},
			components:{
				linkIndex:linkIndex,
			}
		};

		const app = Vue.createApp(PatientData);

		app.use(vant);

		// 通过 CDN 引入时不会自动注册 Lazyload 组件
		// 可以通过下面的方式手动注册
		app.use(vant.Lazyload);

		// 调用函数组件，弹出一个 Toast
		// vant.Toast("刷新成功");

		app.mount("#app");
	</script>

</html>

